/********************************************************************
Name: Figure A3: The Overall Rate of Compliance for Partisan and
	Nonpartisan Sheriffs, 2006-2015
Author: Dan Thompson
Date: August 2019
Notes:
********************************************************************/

* Set the working directory 
gl root = "$sanctuary_root"
gl root = "YOUR_WORKING_DIRECTORY"

* Bring in the TRAC outcome data
use "$root/data/panel of outcomes.dta", clear

* Merge on the information about whether the county has a sheriff
* and whether the election is partisan
gen year = policy_year - 1
merge 1:1 state county year ///
	using "$root/data/manifest summaries and election timing - long.dta", keep(1 3) nogen
keep if no_sheriff==0 

* Plot the total compliance rate in partisan v non-partisan places
collapse (sum) all_sheriff detained_sheriff, by(policy_year partisan)
gen share_detained_sheriff = detained_sheriff/all_sheriff
keep if inrange(policy_year, 2006, 2015)
twoway (connected share_detained_sheriff policy_year if partisan==0, lc(navy) mc(navy)) ///
	(connected share_detained_sheriff policy_year if partisan==1, lc(maroon) mc(maroon)), ///
	legend(order(1 "Non-Partisan" 2 "Partisan")) ///
	xsc(r(2006 2016)) xlab(2006(2)2016) xti("Year") ///
	ysc(r(0 1)) ylab(0(.25)1) ///
	yti("Compliance Rate") ///
	bgcolor(white) graphregion(color(white)) ///
	name("compliance_rate_by_partisan", replace)
